package com.naza.rpc.ratelimit;

import java.util.concurrent.TimeUnit;

public class IntervalRateLimiter extends RateLimiter {

    com.google.common.util.concurrent.RateLimiter limiter;

    public IntervalRateLimiter(Long maxPermits){
        super(maxPermits);
        limiter = com.google.common.util.concurrent.RateLimiter.create(maxPermits);
    }

    @Override
    void acquire() {
        limiter.acquire();
    }

    @Override
    public void acquire(long timeout, TimeUnit unit) {

    }

    @Override
    public long tryAcquire() {
        return limiter.tryAcquire() == true?1L:0;
    }

    @Override
    public void release() {

    }
}
